<template>
	<view class="content">
		<van-form class="login_form">
			<view class="login">登录</view>
			<van-field v-model="form.id_card" placeholder="身份证" class="van_login_input" />
			<van-field v-model="form.password" type="password" placeholder="密码" class="van_login_input" />
			<van-button class="login_button" :disabled="!form.id_card||!form.password" @click="login">登录</van-button>
		</van-form>
	</view>
</template>

<script>
	import {mapGetters} from 'vuex'
	export default {
		data() {
			return {
				form: {
					id_card: '',
					password: ''
				}

			}
		},
		onLoad() {

		},
		computed:	{
			...mapGetters([
				'id_card'
			])
		},
		methods: {
			login() {
				this.$store.dispatch('user/login', this.form).then(() => {
					this.$store.commit('user/SET_ID_CARD',this.form.id_card)
					uni.switchTab({
						url:'../home/index'
					})
				}).catch(err => {
					console.log(err)
				})
			}
		}
	}
</script>

<style>
	.content {
		width: 100%;
		height: 100vh;
		display: flex;
		justify-content: center;
		/* align-items: center; */
		background-color: #ffffff;
	}

	.login {
		font-size: 30px;
		margin: 40px 0;
	}

	.login_form {
		width: 300px;
	}

	.van_login_input {
		margin-bottom: 5px;
		border-bottom: 1px solid #efefef;


	}

	.login_button {
		width: 100%;
		background-color: #007AFF;
		color: #ffffff;
		border-radius: 10px;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
